<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
    <link rel="stylesheet" href="../../static/layui/css/layui.css" th:src="@{/static/layui/css/layui.css}" media="all">
<body>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
      <legend style="font-size: 18px;color: #19a2e3;font-weight: bold">批量转移学员</legend>
    </fieldset>
    <form class="layui-form" id="ccSscBcc" style="margin-left: -40px;padding-right: 10px;">
        <input id="strIds" name="strIds" th:value="${strIds}" type="hidden">
        <div class="layui-form-item" style="padding-top: 15px;">
             <div class="layui-inline">
              <label class="layui-form-label">新CC</label>
              <div class="layui-input-inline">
                <select v-if="ccList.length" name="ccId" lay-search="">
                  <option value="">--请选择新CC--</option>
                  <option  v-for="item in ccList" :value="item.id">{{item.loginName}}</option>
                </select>
              </div>
            </div>
        </div>
         <div class="layui-form-item" style="padding-top: 15px;">
            <div class="layui-inline">
              <label class="layui-form-label">新SSC</label>
              <div class="layui-input-inline">
                <select v-if="sscList.length" name="sscId"  lay-search="">
                  <option value="">--请选择新SCC--</option>
                  <option v-for="item in sscList" :value="item.id">{{item.loginName}}</option>
                </select>
              </div>
            </div>
        </div>
        <div class="layui-form-item" style="padding-top: 15px;">
            <div class="layui-inline">
              <label class="layui-form-label">新BCC</label>
              <div class="layui-input-inline">
                <select  v-if="bccList.length" style="z-index: auto"  name="bccId" lay-search="">
                  <option value="">--请选择新BCC--</option>
                  <option v-for="item in bccList" :value="item.id">{{item.loginName}}</option>
                </select>
              </div>
            </div>
        </div>

        <div class="layui-form-item" style="margin-top: 50px;margin-left: 50px;">
            <div class="layui-input-block">
              <a class="layui-btn layui-btn-warm" lay-submit="" id="btnSave" lay-filter="demo1">确 认</a>
              <a class="layui-btn" onclick="parent.layer.closeAll()" lay-filter="demo1">取 消</a>
            </div>
        </div>
    </form>
    <script src="https://hkres.etalk365.com/public/lib/jquery/jquery.min.js" type="text/javascript"></script>
    <script src="../../static/layui/layui.js" th:src="@{/static/layui/layui.js}" ></script>
    <script type="text/javascript" src="../../static/js/vue.min.js" th:src="@{/static/js/vue.min.js}"></script>
    <script>
        //关闭弹出层
        function layerClose() {
            let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        }
        layui.use(['form', 'layedit', 'laydate','table'], function(){
            var form = layui.form
            ,layer = layui.layer;
            //监听提交
            form.on('submit(demo1)', function(data){
                // * 发起请求
                //debugger
                console.info(data);
                var formData = data.field;
                var counter = 0;
                if(formData.ccId == ''){
                    counter++;
                }
                if(formData.sscId == ''){
                    counter++;
                }
                if(formData.bccId == ''){
                    counter++;
                }
                if(counter == 3){
                    layer.msg("请选择要变更的cc或者ssc或者bcc",{icon: 1});
                    return
                }
                $.ajax({
                    data: {
                        "strIds" : formData.strIds,
                        "ccId" : formData.ccId,
                        "sscId" : formData.sscId,
                        "bccId" : formData.bccId
                    },
                    type: "POST",
                    dataType: "JSON",
                    url: "/personCtl/batchTransfer",
                    // contentType:"application/json;charset=utf-8",
                    beforeSend: function () {
                        // 禁用
                        $("#btnSave").addClass('layui-btn-disabled');
                    },
                    complete: function () {
                        // 启用
                        $("#btnSave").removeClass('layui-btn-disabled');
                    },
                    success: function (result) {
                        if (result.code > 0) {
                           layer.msg("修改成功",{icon: 1});
                           setTimeout(function() {
                              //window.parent.location.reload();
                               window.parent.clickSearch();
                               //layer.close(layer.index);
                               layerClose();
                           },2500)
                        }else{
                           layer.msg("修改失败",{icon: 2});
                        }
                    }
                });
                // end ajax
                return false;
            });
        });
    </script>
    <script>
        $(function() {
            cc_bcc_ssc();
        });

        //cc ssc bcc list
        var ccSscBcc = new Vue({
            el: '#ccSscBcc',
            data: {
                ccList : {

                },
                sscList : {

                },
                bccList : {

                }
            },
        })

        //cc ssc bcc 请求列表
        function cc_bcc_ssc(){
            $.ajax({
                type: 'post',
                url: '/personCtl/getCcOrBccList',
                data: {},
                dataType: 'json',
                async:false,
                success: function (data) {
                    if (data.code == 1) {
                        ccSscBcc.ccList = data.ccList;
                        ccSscBcc.sscList = data.sscList;
                        ccSscBcc.bccList = data.bccList;
                    }
                }
            });
        }

    </script>
</body>
</html>
